<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "exclusive".
 *
 * @property integer $id
 * @property string $title
 * @property integer $type
 * @property string $content
 * @property integer $create_time
 */
class Exclusive extends \yii\db\ActiveRecord
{
    public static $typeArray = array(
        '1'=>'每日喊单',
        '2'=>'新手教程',
        '3'=>'产品规则',
    );
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'exclusive';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['type', 'create_time'], 'integer'],
            [['content'], 'string'],
            [['title'], 'string', 'max' => 256],
            [['title'], 'required'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => '标题',
            'type' => '分类',
            'content' => '正文',
            'create_time' => '创建时间',
        ];
    }

    public function save($runValidation = true, $attributeNames = null)
    {
        if($this->isNewRecord) {
            $this->create_time=time();
        }
        return parent::save($runValidation, $attributeNames);
    }
}
